package com.ala4.oxcafe.boot.authentication;

import com.ala4.oxcafe.boot.manager.UserGrantedAuthority;
import com.ala4.oxcafe.common.utils.collection.CollUtil;
import org.springframework.security.authentication.AbstractAuthenticationToken;

import java.util.Collection;

/**
 * 登录成功token
 *
 * @author PING
 * @version 1.0
 * @date 2025/3/4 18:35
 */
public class CustomAuthenticationToken extends AbstractAuthenticationToken {

    private String token;

    private Object principal;

    public CustomAuthenticationToken(String token, Object principal, Collection<UserGrantedAuthority> authorities) {
        super(authorities);
        this.principal = principal;
        this.token = token;
    }

    public CustomAuthenticationToken(Object principal) {
        this(null, principal, CollUtil.newArrayList());
    }

    @Override
    public Object getCredentials() {
        return token;
    }

    @Override
    public Object getPrincipal() {
        return principal;
    }

}
